<template>
  <div>
    <el-dialog
      title="预览文档"
      :visible.sync="playIsDialog_c"
      @close="resetForm('formName')"
      width="900px"
    >
      <el-form
        :model="ruleForm"
        :rules="rules"
        ref="formName"
        label-width="120px"
        class="demo-ruleForm"
      >
      <iframe
        :src='this.previewWord'
        style="overflow: auto; position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100%"
        ></iframe>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="resetForm('formName')">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script type="text/ecmascript-6">
export default {
  props: {
    wordUrl: {
      type: String,
      default: "",
    },
    playWordIsDialog: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      ruleForm: {
        // 表单字段
      },
      rules: {},
      playIsDialog_c: false, // 弹窗是否显示
      previewWord: "", //预览地址
    };
  },
  watch: {
    playWordIsDialog(val) {
      this.playIsDialog_c = val;
      if (this.playIsDialog_c) {
        this.previewWord = 'https://view.officeapps.live.com/op/view.aspx?src=+this.wordUrl';
      }
    },
  },
  methods: {
    // 取消
    resetForm(formName) {
      // 停止预览
      this.previewWord = "";
   
      this.$refs[formName].resetFields();
      this.$parent.closePlay();
    },
  },
};
</script>

<style lang="less" scoped>
.demo-ruleForm {
  width: 95%;
  margin: 0 auto;
  padding-top: 10px;

  .el-input-number {
    width: 100%;
  }
}

.doc-preview {
    width: 100%;
    height: 800px;
    background-color: #f5f5f5;
}
</style>
